﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace Salary_Emploees
{
    class Program
    {
        static void Main(string[] args)
        {
            Emploee[] nameList = new Emploee[4];
            nameList[0] = new Worker(12000, "Kakashka");
            nameList[1] = new Worker(10000, "Petya");
            nameList[2] = new HourlyWorker(170, 8, "SuperMan");
            nameList[3] = new HourlyWorker(135, 6.5, "SuperWoman");


            foreach (var person in nameList)
            {
                person.CalculateSalary();
            }

        }
    }

    class Emploee
    {
        private string name;

        public Emploee(string name)
        {
            Name = name;
        }

        public string Name
        {
            get
            {
                return name;
            }
            set
            {
                if (String.IsNullOrWhiteSpace(value))
                {
                    throw new ArgumentException("Incorret Name.");
                }
                name = value;
            }
        }

        public virtual void CalculateSalary() { }

    }

    class Worker : Emploee
    {
        private double yearRate;

        public Worker(double rate, string name) : base(name)
        {
            YearRate = rate;
        }

        public double YearRate
        {
            get
            {
                return yearRate;
            }
            set
            {
                if (value<0)
                {
                    throw new ArgumentException("Incorrect value of rate.");
                }
                yearRate = value;
            }

        }

        public override void CalculateSalary()
        {
            Console.WriteLine("Month salary of the worker {0} is - {1:#.##}$.", Name,  YearRate/12);
        }

    }

    class HourlyWorker : Emploee
    {
        private int hours;
        private double hoursRate;

        public HourlyWorker(int hours, double rate, string name) : base(name)
        {
            Hours = hours;
            HoursRate = rate;
        }

        public int Hours
        {
            get
            {
                return hours;
            }
            set
            {
                if (value<0)
                {
                    throw new ArgumentException("Incorrect value of hours.");
                }
                hours = value;
            }
        }

        public double HoursRate
        {
            get
            {
                return hoursRate;
            }
            set
            {
                if (value<0)
                {
                    throw new ArgumentException("Incorrect value of the rate.");
                }
                hoursRate = value;
            }
        }

        public override void CalculateSalary()
        {
            Console.WriteLine("Amount of earned money of the hourly worker {0} is - {1:#.##}$.", Name,  HoursRate * Hours);
        }

    }
}
